{{include file="Manage/header.html"}}
<body>
{{include file="Manage/menu.html"}}
<div class="edit_pro">
    <div class="bule_bg"></div>
    <form method="post" onsubmit="return false" action="index.php?app=Myproject&act=file">
        <input name="id" value="{{if $project.id}}{{$project.id}}{{/if}}" type="hidden">
        <div class="content">
            <div class="title">创建项目</div>
            <div class="basic_infor">
                <div class="head">
                    <span>基本信息</span>
                </div>
                <div class="container">
                    <span>*</span>项目名称
                    <input type="text" name="project" id="inputl" placeholder="简洁清晰，不多于10个字" maxlength="10" value="{{if $project.project}}{{$project.project}}{{/if}}">
                </div>
                <div class="container">
                    <span class="field">
                        <span>*</span>所属领域
                    </span>
                    <select data-placeholder="请选择所属于领域" class="chosen-select" multiple tabindex="4">
                        <option value=""></option>
                        {{if $field}}
                        {{foreach from=$field item=val key=key}}
                            <option value="{{$key}}" {{foreach from=$project.field item=val2}} {{if $val2 == $key}}selected="true"{{/if}}{{/foreach}}>{{$val}}</option>
                        {{/foreach}}
                        {{/if}}
                    </select>
                    <input type="hidden" name="field">
                </div>
            </div>
            <div class="pro_intro">
                <div class="head">
                    <span>项目介绍</span>
                </div>
                <div class="container">
                    <div class="name">
                        <span>*</span>项目描述
                    </div>
                    <textarea placeholder="可拆分为产品描述、用户群体、项目愿景、竞争对手等方面详细描述" name="params[descride]" id="txt1">{{$project.params.descride}}</textarea>
                    <div class="limit"><span id="word1">150</span>/150</div>
                </div>
                <div class="container">
                    <div class="name1">
                        <span>*</span>负责人简介
                    </div>
                    <textarea placeholder="介绍自己" name="params[personal]" id="txt2">{{$project.params.personal}}</textarea>
                    <div class="limit"><span id="word2">150</span>/150</div>
                </div>
            </div>
            <div class="upload">
                <div class="head">
                    <span>项目上传</span>
                </div>
                <div class="container">
                    <div class="name2">
                        <span>*</span>项目计划书
                    </div>
                    <div class="upload_file">
                        <a  href="javascript:" class="sim_file">
                            {{if $project.files}}重新上传{{else}}上传项目{{/if}}
                            <input type="file" name="upload" placeholder="请选择上传文件" id="upload" value="{{$project.files}}">
                        </a>
                        <span class="showFileName1">{{if $project.files}}{{$project.project}}{{else}}未上传文件{{/if}}</span>
                    </div>
                    <p class="notes">格式为压缩包zip或者word，不超过2M，文件数量限一个。</p>
                    <input type="hidden" name="files" value="{{$project.files}}">
                </div>
            </div>
            <button onclick="detail()">确定</button>
        </div>
    </form>
</div>

<script src="{{$smarty.const.__APP__}}manage/js/chosen.jquery.js" type="text/javascript"></script>
<script src="{{$smarty.const.__APP__}}manage/js/prism.js" type="text/javascript" charset="utf-8"></script>
<script src="{{$smarty.const.__APP__}}manage/js/init.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

    $(function(){

        $(".chosen-search-input").focus(function(){
            $(this).css("box-shadow","none");
        });

        // 限制字数
        $("#inputl").keyup(function(){
            if($("#inputl").val().length > 10){
                $("#inputl").val( $("#inputl").val().substring(0,10) );
            }
        })

        $("#txt1").keyup(function(){
            if($("#txt1").val().length > 150){
                $("#txt1").val( $("#txt1").val().substring(0,150) );
            }
            $("#word1").text( 150 - $("#txt1").val().length ) ;
        });
        $("#txt2").keyup(function(){
            if($("#txt2").val().length > 150){
                $("#txt2").val( $("#txt2").val().substring(0,150) );
            }
            $("#word2").text( 150 - $("#txt2").val().length ) ;
        });
    })

    function detail(){
        field_f();
        var field = $("input[name=field]").val();
        if(field == ''){
            ui.error('请至少选择一个项目！');
            return false;
        }
        var params = $("form").serialize();
        $.post('{{"index.php?app=Myproject&act=modify"|URL}}',params,function(result){
            if(result.statusCode=='200'){
                ui.success(result.message);
                setTimeout(function(){
                    var url = "{{$smarty.const.__PROJECT__}}Myproject/student";
                    document.location.href = url;//登录后跳转页面
                },1000);
            }else if(result.statusCode=='300') ui.error(result.message);
        },'json');
    }

    function field_f(){
        var field = '';
        $.each($('.search-choice'),function(){
            field += ","+$(this).find("a").attr('data-option-array-index');
        })
        $("input[name=field]").val(field.substr(1));
    }

    //文件
    $("#upload").change(function(){
        $("form").ajaxSubmit({
            dataType:  'json',
            success: function(result) {
                if(result.statusCode == '200'){
                    $("input[name=files]").val(result.message);
                    $(".sim_file").html('已上传');
                    $(".showFileName1").html(result.data);
                }
                else if(result.statusCode == '300'){
                    $("input[name=files]").val("{{$project.files}}");
//                    $("#pic").attr('src',"{{$result.image|photo}}");
                    $(".showFileName1").html(result.message);
                    ui.error(result.message);
                }
            }
        });
    });
</script>
{{include file="Manage/footer.html"}}